#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Drawing;
using System.Text;
using EstateNuke.Data;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;

#endregion

namespace EstateNuke.BusinessSystem.Controls.EstateControls
{
    public partial class EntranceViewControl : UserControl
    {
        private Entrance _currentEntrance;
        private Building _currentBuilding;
        private RoomOperationType _roomOperationType;
        public EntranceViewControl(Entrance entrance, Building building, RoomOperationType type)
        {
            _currentEntrance = entrance;
            _currentBuilding = building;
            _roomOperationType = type;

            InitializeComponent();
            BindEntrance();

            this.Width = _currentEntrance.RoomsNumberPerFloor * (Constant.ViewRoomWidth + 4);
            this.Height = _currentBuilding.Floors.Count * (Constant.ViewRoomHeight + 4) + pnlTitle.Height;
        }

        private void BindEntrance()
        {
            foreach (var floor in _currentBuilding.Floors.OrderByDescending(c=>c.Number))
            {
                RoomGroupViewControl roomGroup = new RoomGroupViewControl(_currentEntrance, floor, _roomOperationType);
                flpRoomContainer.Controls.Add(roomGroup);
            }
        }
        public void ClearEntrance()
        {
            flpRoomContainer.Controls.Clear();
        }

        private void EntranceViewControl_Load(object sender, EventArgs e)
        {
            lblEntranceName.Text = _currentEntrance.DisplayName;

            lblEntranceName.Left = Width / 2 - lblEntranceName.Width / 2;
            lblEntranceName.Top = pnlTitle.Height / 2 - lblEntranceName.Height / 2;
        }
    }
}